#
# "@(#) $Id: LMultipleDrag.py,v 1.1.1.1 2006-07-27 03:16:08 gioshe Exp $"
#
# This work is released under the GNU GPL, version 2 or later.
#
from qt import *

class MultipleDrag(QDragObject):
	def __init__(self,dragSource = None,name = None):
		QDragObject.__init__(self,dragSource,name)
		self.m_dragObjects = []
		self.m_numberFormats = []

	def addDragObject(self,dragObject):
		self.m_dragObjects.append(dragObject)
		i = 0
		while dragObject.format(i):
			i = i+1
		self.m_numberFormats.append(i)
			
	def encodedData(self,mime):
		for dragObject in self.m_dragObjects:
			i = 0
			while dragObject.format(i):
				if dragObject.format(i)==mime:
					return dragObject.encodedData(mime)
				i = i+1
		return QByteArray()

	def format(self,i):
		index = 0
		for dragObject in self.m_dragObjects:
			if i<self.m_numberFormats[index]:
				return dragObject.format(i)
			i = i - self.m_numberFormats[index]
			index = index+1
		return None
